﻿@model SCMS.UI.Models.RequestReviewModel
@{
    int numReview = 0;
    int procReview = 0;
    int finReview = 0;
    int totalNotif = 0;
    string notifClass = "";
    string notifTitle = "";
    string notifValue = "";
    procReview += Model.OrderRequests != null ? Model.OrderRequests.Count : 0;
    procReview += Model.TenderAnalyses != null ? Model.TenderAnalyses.Count : 0;
    procReview += Model.PurchaseOrders != null ? Model.PurchaseOrders.Count : 0;

    finReview += Model.PaymentRequests != null ? Model.PaymentRequests.Count : 0;

    numReview = procReview + finReview;

    int numAuth = 0;
    int procAuth = 0;
    int finAuth = 0;
    procAuth += Model.AuthOrderRequests != null ? Model.AuthOrderRequests.Count : 0;
    procAuth += Model.AuthTenderAnalyses != null ? Model.AuthTenderAnalyses.Count : 0;
    procAuth += Model.AuthPurchaseOrders != null ? Model.AuthPurchaseOrders.Count : 0;

    finAuth += Model.AuthPaymentRequests != null ? Model.AuthPaymentRequests.Count : 0;    

    numAuth = procAuth + finAuth;

    totalNotif = numReview + numAuth;
    if (totalNotif > 1)
    {
        notifClass = "notification noti-yellow";
        notifTitle = string.Format("You have {0} notifications", totalNotif);
        notifValue = totalNotif.ToString();
    }
    else if(totalNotif == 1)
    {
        notifClass = "notification noti-yellow";
        notifTitle = string.Format("You have {0} notification", totalNotif);
        notifValue = totalNotif.ToString();
    }
    else
    {
        notifClass = "notification noti-blue";
        notifTitle = "You have no notifications at this time";
        notifValue = "!";
    }
    
}
<div style="width:auto;">                    
    <dl class="dropdown" style="">
        <dt>
            <span id="linkglobal" class="@notifClass" title="@notifTitle">@notifValue</span>
        </dt>
        <dd>
            <div id="notification">
                <ul id="noti-root" style="display: none;">
                    <li>
                        @if (numAuth > 0)
                        {
                            <a href="#" class="m-title"><b>AUTHORIZATION (@numAuth)</b></a>
                        }
                        else
                        { 
                            <a href="#" class="m-title">AUTHORIZATION (NO)</a>
                        }
                        <ul>
                            <li><a href="#" title="">ALL DOCUMENTS (NO)</a></li>
                            <li>                    
                                @if (finAuth > 0)
                                {
                                    <a href="#" title="" class="m-title"><b>RFP – ECF – SPM (@finAuth)</b></a>  
                                    <ul>
                                    @if (Model.AuthPaymentRequests != null && Model.AuthPaymentRequests.Count > 0)
                                    {
                                        <li><a href="#" title="" class="m-title">REQUESTS FOR PAYMENT <b>(@Model.AuthPaymentRequests.Count)</b></a>
                                        <ul>
                                            @foreach (var rfp in Model.AuthPaymentRequests)
                                            { 
                                                <li>
                                                    @Ajax.ActionLink(rfp.EntityPaymentRqst.RefNumber, "../RequestReview/", new { id = "LoadRFPForAuth" }, new AjaxOptions
                                               {
                                                   OnBegin = "ShowDialogueOR('Authorize Request For Payment: " + rfp.EntityPaymentRqst.RefNumber + "')",
                                                   UpdateTargetId = "popup-page",
                                                   LoadingElementId = "popup-loading",
                                                   Url = Url.Action("../RequestReview/LoadRFPForAuth/" + rfp.EntityPaymentRqst.Id),
                                                   OnSuccess = "CenterPopupRFP"
                                               }, new { @class = "reviewLink" }) 
                                                </li>
                                            }
                                        </ul>
                                        </li>
                                    }                        
                                    </ul>                 
                                }
                                else
                                { 
                                    <a href="#" title="">RFP – ECF – SPM (NO)</a>
                                }
                            </li> 
                            <li>
                            @if (procAuth > 0)
                            {
                                <a href="#" title="" class="m-title"><b>OR – TA – PO (@procAuth)</b></a>                   
                            }
                            else
                            { 
                                <a href="#" title="">OR – TA – PO (NO)</a>
                            }
                            <ul>
                            @if (Model.AuthOrderRequests != null && Model.AuthOrderRequests.Count > 0)
                            {
                                <li><a href="#" title="" class="m-title">ORDER REQUESTS <b>(@Model.AuthOrderRequests.Count)</b></a>
                                <ul>
                                    @foreach (var or in Model.AuthOrderRequests)
                                    { 
                                        <li>
                                            @Ajax.ActionLink(or.ORRefNo, "../RequestReview/", new { id = "LoadOrderRequestForAuth" }, new AjaxOptions
                                       {
                                           OnBegin = "ShowDialogueOR('Authorize Order Request: " + or.ORRefNo + "')",
                                           UpdateTargetId = "popup-page",
                                           LoadingElementId = "popup-loading",
                                           Url = Url.Action("../RequestReview/LoadOrderRequestForAuth/" + or.ORID),
                                           OnSuccess = "CenterPopupOR"
                                       }, new { @class = "reviewLink" }) 
                                        </li>
                                    }
                                </ul>
                                </li>
                            }
                            @if (Model.AuthTenderAnalyses != null && Model.AuthTenderAnalyses.Count > 0)
                            {
                                <li><a href="#" title="" class="m-title">TENDER ANALYSES <b>(@Model.AuthTenderAnalyses.Count)</b></a>
                                <ul>
                                @foreach (var ta in Model.AuthTenderAnalyses)
                                {
                                    <li>
                                        @Ajax.ActionLink(ta.EntityTenderAnalysis.RefNumber, "../RequestReview/", new { id = "LoadOrderRequest" }, new AjaxOptions
                                   {
                                       OnBegin = "ShowDialogueOR('Authorize Tender Analysis: " + ta.EntityTenderAnalysis.RefNumber + "')",
                                       UpdateTargetId = "popup-page",
                                       LoadingElementId = "popup-loading",
                                       Url = Url.Action("../RequestReview/LoadOrderRequest/" + ta.EntityTenderAnalysis.Id),
                                       OnSuccess = "CenterPopupOR"
                                   }, new { @class = "reviewLink" }) 
                                    </li>
                                }
                                </ul>
                                </li>
                            }
                            @if (Model.AuthPurchaseOrders != null && Model.AuthPurchaseOrders.Count > 0)
                            { 
                                <li><a href="#" title="" class="m-title">PURCHASE ORDERS <b>(@Model.AuthPurchaseOrders.Count)</b></a>
                                <ul>
                                @foreach (var po in Model.AuthPurchaseOrders)
                                {
                                    <li>
                                        @Ajax.ActionLink(po.POEntiy.RefNumber, "../RequestReview/", new { id = "LoadPurchaseOrderForAuth" }, new AjaxOptions
                                   {
                                       OnBegin = "ShowDialogueOR('Authorize Purchase Order: " + po.POEntiy.RefNumber + "')",
                                       UpdateTargetId = "popup-page",
                                       LoadingElementId = "popup-loading",
                                       Url = Url.Action("../RequestReview/LoadPurchaseOrderForAuth/" + po.POEntiy.Id),
                                       OnSuccess = "CenterPopupPO"
                                   }, new { @class = "reviewLink" }) 
                                    </li>
                                }
                                </ul>
                                </li>
                            } 
                            </ul></li>               
                            <li><a href="#" title="">WRN (NO)</a></li>
                            <li><a href="#" title="">TAF (NO)</a></li>
                        </ul>
                    </li>
                    <li>
                        @if (numReview > 0)
                        {
                            <a id="notHeader" href="#" class="m-title"><b>NOTIFICATIONS (@numReview)</b></a>
                        }
                        else
                        { 
                            <a id="notHeader" href="#" class="m-title">NOTIFICATIONS (NO)</a>
                        }
                        <ul>
                            <li><a href="#" title="">ALL DOCUMENTS (NO)</a></li>
                            <li>
                                @if (finReview > 0)
                                {
                                    <a href="#" title="" class="m-title"><b>RFP – ECF – SPM (@finReview)</b></a>  
                                    <ul>
                                    @if (Model.PaymentRequests != null && Model.PaymentRequests.Count > 0)
                                    {
                                        <li><a href="#" title="" class="m-title">REQUESTS FOR PAYMENT <b>(@Model.PaymentRequests.Count)</b></a>
                                        <ul>
                                            @foreach (var rfp in Model.PaymentRequests)
                                            { 
                                                <li>
                                                    @Ajax.ActionLink(rfp.EntityPaymentRqst.RefNumber, "../RequestReview/", new { id = "ReviewRFP" }, new AjaxOptions
                                               {
                                                   OnBegin = "ShowDialogueOR('Review Request For Payment: " + rfp.EntityPaymentRqst.RefNumber + "')",
                                                   UpdateTargetId = "popup-page",
                                                   LoadingElementId = "popup-loading",
                                                   Url = Url.Action("../RequestReview/ReviewRFP/" + rfp.EntityPaymentRqst.Id),
                                                   OnSuccess = "CenterPopupRFP"
                                               }, new { @class = "reviewLink" }) 
                                                </li>
                                            }
                                        </ul>
                                        </li>
                                    }                        
                                    </ul>                 
                                }
                                else
                                { 
                                    <a href="#" title="">RFP – ECF – SPM (NO)</a>
                                }
                            </li>
                            <li>
                                @if (procReview > 0)
                                {
                                    <a href="#" title="" class="m-title"><b>OR – TA – PO (@procReview)</b></a>
                                }
                                else
                                { 
                                    <a href="#" title="">OR – TA – PO (NO)</a>
                                }
                                <ul>
                                @if (Model.OrderRequests != null && Model.OrderRequests.Count > 0)
                                {
                                    <li><a href="#" title="" class="m-title">ORDER REQUESTS <b>(@Model.OrderRequests.Count)</b></a>
                                    <ul>
                                        @foreach (var or in Model.OrderRequests)
                                        { 
                                            <li>
                                                @Ajax.ActionLink(or.ORRefNo, "../RequestReview/", new { id = "LoadOrderRequest" }, new AjaxOptions
                                           {
                                               OnBegin = "ShowDialogueOR('Review Order Request: " + or.ORRefNo + "')",
                                               UpdateTargetId = "popup-page",
                                               LoadingElementId = "popup-loading",
                                               Url = Url.Action("../RequestReview/LoadOrderRequest/" + or.ORID),
                                               OnSuccess = "CenterPopupOR"
                                           }, new { @class = "reviewLink" }) 
                                            </li>
                                        }
                                    </ul>
                                    </li>
                                }
                                @if (Model.TenderAnalyses != null && Model.TenderAnalyses.Count > 0)
                                {
                                    <li><a href="#" title="" class="m-title">TENDER ANALYSES <b>(@Model.TenderAnalyses.Count)</b></a>
                                    <ul>
                                    @foreach (var ta in Model.TenderAnalyses)
                                    {
                                        <li>
                                            @Ajax.ActionLink(ta.EntityTenderAnalysis.RefNumber, "../RequestReview/", new { id = "ReviewTA" }, new AjaxOptions
                                       {
                                           OnBegin = "ShowDialogueOR('Review Tender Analysis: " + ta.EntityTenderAnalysis.RefNumber + "')",
                                           UpdateTargetId = "popup-page",
                                           LoadingElementId = "popup-loading",
                                           Url = Url.Action("../RequestReview/ReviewTA/" + ta.EntityTenderAnalysis.Id),
                                           OnSuccess = "CenterPopup"
                                       }, new { @class = "reviewLink" }) 
                                        </li>
                                    }
                                    </ul>
                                    </li>
                                }    
                                @if (Model.PurchaseOrders != null && Model.PurchaseOrders.Count > 0)
                                { 
                                    <li><a href="#" title="" class="m-title">PURCHASE ORDERS<b> (@Model.PurchaseOrders.Count)</b></a>
                                    <ul>
                                    @foreach (var po in Model.PurchaseOrders)
                                    {
                                        <li>
                                            @Ajax.ActionLink(po.POEntiy.RefNumber, "../RequestReview/", new { id = "LoadPurchaseOrder" }, new AjaxOptions
                                       {
                                           OnBegin = "ShowDialogueOR('Review Purchase Order: " + po.POEntiy.RefNumber + "')",
                                           UpdateTargetId = "popup-page",
                                           LoadingElementId = "popup-loading",
                                           Url = Url.Action("../RequestReview/LoadPurchaseOrder/" + po.POEntiy.Id),
                                           OnSuccess = "CenterPopupPO"
                                       }, new { @class = "reviewLink" }) 
                                        </li>
                                    }
                                    </ul>
                                    </li>
                                }   
                                </ul>                                   
                            </li>
                            <li><a href="#" title="">WRN (NO)</a></li>
                            <li><a href="#" title="">TAF (NO)</a></li>
                            <li><a href="#" title="">GRN - WB (NO)</a></li>
                        </ul>
                    </li>        
                </ul>
            </div>
        </dd>
    </dl>
</div>